using System;
using System.Collections.Generic;
using System.Linq;
using Shell.Common;
using Shell.KnowledgeBase;

namespace Shell
{
    public static class Utils
    {
        private const bool Expand = true;

        public static Statement CreateAtomicStatement(this string atomValue)
        {
            return new Statement(
                new Atom(atomValue).Yield());
            
        }

        public static IEnumerable<T> Do<T>(this IEnumerable<T> source)
        {
            return Expand 
                       ? source.ToArray()
                       : source;
        }

        public static string[] Tokenize(string value)
        {
            return value.Split(' ').Where(_ => !String.IsNullOrWhiteSpace(_)).ToArray();
        }
    }
}